#include <bits/stdc++.h>
 
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
 
using namespace std;
 
#define nullptr NULL // for some oj not supporting c++11.
 
int getint(int x=0)
{
    char c=getchar(); bool mi = false;
    while(c!='-' && (c<'0' || '9'<c)) c=getchar();
    if(c=='-') { mi=true; c=getchar(); }
    x=c-'0';
    while('0'<=(c=getchar()) && c<='9') x=x*10+c-'0';
    return mi ? -x : x;
}
db getdb(db x=0.0) { scanf("%lf",&x); return x; }
 
//========================================

const int mxn = 105000;

struct edge{ int in; edge*nxt; } pool[mxn];
edge*eds[mxn]; edge*et=pool;
void addedge(int a,int b){ et->in=b; et->nxt=eds[a]; eds[a]=et++; }
#define FOREACH_EDGE(e,x) for(edge*e=eds[x];e;e=e->nxt)

// verteces part.
int n;
int c[mxn]; // whitch chain this vertex belongs to.
int f[mxn];
int mxi[mxn]; // record the heavy chain target for every node to build dfsn.

// chain part.
int ct; // chain count.
int ch[mxn]; // chain head.
int clen[mxn]; // chain length.
int cloc[mxn]; // chain beginning location;
               // end location is *NOT* cloc[i+1]-1 but cloc[i]+cl[i]-1.

// return the depth of this subtree. 
int q[mxn]; int qh,qt;
void BuildChain(int root) // use topo-order to avoid stack overflow.
{
    q[qt++]=root;
    f[root]=-1; // do not change.
    while(qh!=qt) { int x=q[qh++]; FOREACH_EDGE(e,x) q[qt++]=e->in; }
    for(int i=n-1;i>=0;i--)
    {
        int x=q[i];
        if(!eds[x]) { ch[ct]=x; clen[ct]=1; c[x]=ct++; continue; }        
        int mxp = eds[x]->in;
        FOREACH_EDGE(e,x)
        {
            f[e->in] = x;
            if(clen[c[e->in]]>clen[c[mxp]]) mxp=e->in;
        }
        c[x] = c[mxi[x] = mxp]; clen[c[x]]++; ch[c[x]] = x;
    }
}

int loc[mxn]; // which location this vertex belongs to.
int til[mxn]; // the node leading subtree's tail location.
int curl; // current loc pointer.
void BuildDFSOrder(int x)
{
    loc[x] = curl++;
    if(x==ch[c[x]]) cloc[c[x]]=loc[x];
    if(eds[x]) BuildDFSOrder(mxi[x]);
    FOREACH_EDGE(e,x) if(e->in!=mxi[x]) BuildDFSOrder(e->in);
    til[x] = curl-1;
}

void MakeDecomposition()
{
    int root = 0;
    BuildChain(root);
    
    //for(int i=0;i<n;i++) printf("[%d] c:%d hv:%d\n",i,c[i],mxi[i]);
    //for(int i=0;i<ct;i++) printf("<%d> head:%d len:%d\n",i,ch[i],cl[i]);
    
    BuildDFSOrder(root);
    
    //for(int i=0;i<n;i++) printf("[%d] [%d,%d]\n",i,loc[i],til[i]);
    //for(int i=0;i<ct;i++) printf("<%d> [%d,%d]\n",i,cloc[i],cloc[i]+clen[i]-1);
}


/// Segment Tree
#define L (x<<1)
#define R (x<<1|1)
int t[mxn<<3]; // true value.
int tag[mxn<<3]; // change tag. -1: clear; 1: install; 0:none.
inline void pushtag(int x,int l,int r) // leaf won't call in this function.
{
    if(tag[x]==0) return; // has nothing to change.
    tag[L] = tag[R] = tag[x]; // merge subnode's tags.
    // change subnode's true value.
    int mid = (l+r)>>1;
    if(tag[x]==-1) { t[L]=t[R]=0; }
    else if(tag[x]==1) { t[L]=mid-l+1; t[R]=r-mid; }
    tag[x]=0;
}
inline void Update(int x,int l,int r) // leaf won't call in this function.
{ t[x] = t[L] + t[R]; }

int cl, cr, cv;
void Change(int x=1, int l=0, int r=n-1)
{
    if(cr<l || r<cl) return; // do nothing out of changing range.
    if(cl<=l && r<=cr)
        { tag[x] = cv; t[x] = ( tag[x]==-1 ? 0 : r-l+1 ); return; }
    pushtag(x,l,r);
    int mid = (l+r)>>1;
    Change(L,l,mid); Change(R,mid+1,r); Update(x,l,r);
}
void Modify(int l,int r,int v)
{
    //printf("Modify: [%d,%d] to %d\n",l,r,v);
    cl=l; cr=r; cv=v;
    Change(); 
}

int ql,qr;
int Query(int x=1, int l=0, int r=n-1)
{
    pushtag(x,l,r);
    if(qr<l || r<ql) return 0;
    if(cl<=l && r<=cr) return t[x];
    int mid = (l+r)>>1;
    return Query(L,l,mid) + Query(R,mid+1,r);
}
int GetTotalSum() { return t[1]; }



void Install(int p)
{
    //printf("Install!\n");
    do { Modify(loc[ch[c[p]]],loc[p],1); p=f[ch[c[p]]]; }
    while(p!=-1); // -1 is the parent node of root.
}

void Remove(int p)
{
    //printf("Remove!\n");
    Modify(loc[p], til[p],-1);
}

int main()
{
    n=getint();
    for(int i=1;i<n;i++) addedge(getint(),i);
    int m=getint();
    
    MakeDecomposition();
    
    int ca = 0;
    for(int i=0;i<m;i++)
    {
        char inp[15];
        scanf("%s",inp);
        if(inp[0]=='u')
        {
            Remove(getint());
            printf("%d\n",ca-GetTotalSum());
        }
        else if(inp[0]=='i')
        {
            Install(getint());
            printf("%d\n",GetTotalSum()-ca);
        }
        ca = GetTotalSum();
    }
    
    
    return 0;
}


/*

7
0 0 0 1 1 5
5
install 5
install 6
uninstall 1
install 4
uninstall 0

*/
